import { IPSSysBICubeDimension } from './ipssys-bicube-dimension';
import { IPSSysBICubeLevel } from './ipssys-bicube-level';
import { IPSSysBIDimension } from './ipssys-bidimension';
import { IPSSysBIScheme } from './ipssys-bischeme';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysBICubeDimensionImpl extends PSModelObjectImpl implements IPSSysBICubeDimension {
  protected allpssysbicubelevels: IPSSysBICubeLevel[] | null = null;

  getAllPSSysBICubeLevels(): IPSSysBICubeLevel[] | null {
    if (this.allpssysbicubelevels == null) {
      this.allpssysbicubelevels = this.fillChildListModel(this.M.getAllPSSysBICubeLevels, 'bi.IPSSysBICubeLevel') as IPSSysBICubeLevel[];
    }
    return this.allpssysbicubelevels;
  }

  get allPSSysBICubeLevels(): IPSSysBICubeLevel[] | null {
    return this.getAllPSSysBICubeLevels();
  }

  findPSSysBICubeLevel(objKey: any): IPSSysBICubeLevel | null {
    return this.getPSModel5('bi.IPSSysBICubeLevel', this.getAllPSSysBICubeLevels(), objKey) as IPSSysBICubeLevel;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dimensionTag(): string {
    return this.M.dimensionTag;
  }

  get dimensionTag2(): string {
    return this.M.dimensionTag2;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdefield = ipsdataentity.findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定实体属性');
    }
    return value;
  }

  protected pssysbidimension: IPSSysBIDimension | null = null;

  getPSSysBIDimension(): IPSSysBIDimension | null {
    if (this.pssysbidimension != null) return this.pssysbidimension;
    const value = this.M.getPSSysBIDimension;
    if (value == null) {
      return null;
    }
    const ipssysbischeme = this.getParentPSModelObject('bi.IPSSysBIScheme') as IPSSysBIScheme;
    if (ipssysbischeme != null) {
      this.pssysbidimension = ipssysbischeme.findPSSysBIDimension(value);
    }
    return this.pssysbidimension;
  }

  get psSysBIDimension(): IPSSysBIDimension | null {
    return this.getPSSysBIDimension();
  }

  getPSSysBIDimensionMust(): IPSSysBIDimension {
    const value = this.getPSSysBIDimension();
    if (value == null) {
      throw new Error('未指定智能报表维度');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysBICubeDimensionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'bi.IPSBICubeDimension' || cls == 'bi.IPSSysBICubeDimension') return true;
    return super.instanceof(cls);
  }
}
